{{include file="header.html"}}
	<div class="header loginhead">
		<div class="nav">
		    <div class="search return"><a href="index.php?app=Login"></a></div>
		    <div class="title">找回密码</div>
		    <div class="right">
		        <a href="{{$smarty.const.__PROJECT__}}"><img src="{{$smarty.const.__APP__}}images/homeon.png" alt=""></a>
		    </div>
		</div>
	</div>
	<div class="container login">
		<div class="loginbox">
			<form action="" class="lForm">
				<div class="login_wrap tel">
					<span class="icon">
						<img src="{{$smarty.const.__APP__}}images/tel.png" alt="">
					</span>
					<div class="input_text">
						<input name="tel" type="tel" placeholder="请输入手机号" id="tel">
					</div>
					<a class="verifybtn" id='sms-btn'>获取验证码</a>
				</div>
				<div class="login_wrap ver">
					<span class="icon">
						<img src="{{$smarty.const.__APP__}}images/verify.png" alt="">
					</span>
					<div class="input_text">
						<input name="sms_code" type="tel" placeholder="请输入验证码" id="ver">
					</div>
				</div>	
				<div class="login_wrap">
					<span class="icon">
						<img src="{{$smarty.const.__APP__}}images/pw.png" alt="">
					</span>
					<div class="input_text">
						<input name="password" type="password" placeholder="请输入新密码">
					</div>
				</div>	
				<div class="login_wrap">
					<span class="icon">
						<img src="{{$smarty.const.__APP__}}images/pw.png" alt="">
					</span>
					<div class="input_text">
						<input name="password2" type="password" placeholder="确认新密码">
					</div>
				</div>	
				<div class="loginbtn">
					<a href="javascript:" class="btn-login">确认修改</a>
				</div>
			</form>	
		</div>
	</div>
<style>
.btn-retransmit-disabled {
	cursor:default;
	color:#bdbdbd
}	
</style>
<script type="text/javascript">

	//点击获取号码
	$(".verifybtn").click(function(){
		if($('#sms-btn').hasClass("btn-retransmit-disabled")) return false;
		dysms();
	})

	//获取验证码
	var dysms = function(){
		//获取号码
		var tel = $("#tel").val();
		//异步提交
		$.post('{{"index.php?app=Login&register"|URL}}',{'tel':tel},function(result){
	        if(result.statusCode=='200'){
	        	set_time(1);
	        	ui.success('短信发送成功!');
	        	setCookie('sms',result.message,'5');
	        	$('#sms-btn').addClass("btn-retransmit-disabled");
	        } 
	        else ui.error(result.message);
	    },'json');
	}

	//提交修改
	$(function(){
		$('.btn-login').click(function(){
			if(!$('#sms-btn').hasClass("btn-retransmit-disabled")){
				ui.error('请重新获取验证码!');
				return false;
			} 
			//获取短信验证码
			var sms = getCookie("sms");
			//获取输入的验证码
			var code = $("#ver").val();
			//验证码正确与否
			if(sms == code && sms != ''){
				var params = $("form").serialize();
				$.post('{{"index.php?app=Login&getpassword"|URL}}',params,function(result){
			        if(result.statusCode=='200'){
			        	ui.success(result.message);
			        	setTimeout(function(){
							location.href='{{"index.php?app=Login"|URL}}';
						},1000);
			        }else ui.error(result.message);
			    },'json');
			}else if(!$("#tel").val()){
				ui.error('手机号码错误!');
				return false;
			}else if(!$('#sms-btn').hasClass("btn-retransmit-disabled")){
				ui.error('请获取验证码!');
				return false;
			}else{
				ui.error('验证码错误!');
				$("#ver").val("");
				return false;
			}
		})
	})
</script>
{{include file="footer.html"}}